package mylibrary.ejb.v2;

import java.util.Calendar;
import java.util.Hashtable;

import javax.naming.Context;
import javax.naming.InitialContext;

import mylibrary.ejb.v2.cmp.CustomerEntityHome;
import mylibrary.ejb.v2.cmp.CustomerEntityRemote;
import mylibrary.ejb.v2.cmp.CustomerVO;

import mylibrary.ejb.v2.sample.CustomerBean;
import mylibrary.ejb.v2.sample.CustomerHome;
import mylibrary.ejb.v2.sample.CustomerRemote;

//import weblogic.rmi.extensions.PortableRemoteObject;


public class Client {

public static void main(String[] args) throws Exception {
		
		Hashtable ht = new Hashtable();  
		ht.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
		ht.put(Context.PROVIDER_URL, "t3://localhost:7001");
		Context ctx = new InitialContext(ht);
		
//		Session Bean
//		Object obj = ctx.lookup("ejb/test");
//		CustomerHome home = (CustomerHome) PortableRemoteObject.narrow(obj, CustomerHome.class);
//		System.out.println(home.getClass().getName());
//		
//		CustomerRemote bean = (CustomerRemote)home.create();
//		System.out.println(bean.getClass().getName());
//		
//		bean.hello();
		
		
		
		//Entity CMP Bean
		Object obj = ctx.lookup("ejb/customerVO");
		
		//create
		//CustomerEntityHome home = (CustomerEntityHome) PortableRemoteObject.narrow(obj, CustomerEntityHome.class);
		
//		CustomerEntityRemote  entity = home.create(new CustomerVO(101, "gaoshuaidage"));
		
//		Integer primaryKey = (Integer) entity.getPrimaryKey();
		
		//read
		//CustomerEntityRemote customer_find = home.findByPrimaryKey(1);
		
		
		//update fields
		//customer_find.setFirstName("hello");
		
		//delete
		//customer_find.remove();
		
		
		//customer_find.says("1111111");
	}
}










